import useClipboard from 'vue-clipboard3'
import { gp } from '@vui'
import { translateTitle } from '@/utils/i18n'
//复制到剪切板
export function clipboard(content = '', showMsg = true) {
  const { toClipboard } = useClipboard()

  const copy = async (text) => {
    try {
      await toClipboard(text)
      if (showMsg) gp.$baseMessage(translateTitle('Ve.utils.复制成功'), 'success')
    } catch (e) {
      console.error(e)
      gp.$baseMessage(translateTitle('Ve.utils.复制失败'), 'warning')
    }
  }
  return copy(content)
}
